/**
 * inverse modulo
 * @author Jarvan
 * @version 1.0
 * @create 2020/10/30 20:23
 */
public class modInverse {
    public static void main(String[] args) {
        int i = new modInverse().modInverse(3, 7);
        System.out.println(i);
    }
    int modInverse(int a, int m) {
        a %= m;
        for(int x = 1; x < m; x++) {
            if((a*x) % m == 1) {
                return x;
            }
        }
        return  -1;
    }

}
